package com.chuangke.mds.listener;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.chuangke.common.enums.OrderStatusEnum;
import com.chuangke.flow.listener.Listener;
import com.chuangke.flow.listener.ListenerVariable;
import com.chuangke.mds.dao.TechnologyProcessDao;
import com.chuangke.mds.entity.TechnologyProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author panyingzu
 * @title TaskApprovalAgainListener
 * @description
 * @Date 2025/9/19 7:15
 */
@Component
public class TaskApprovalSecListener implements Listener {

    private static final Logger log = LoggerFactory.getLogger(TaskApprovalSecListener.class);

    @Autowired
    private TechnologyProcessDao technologyProcessDao;

    @Override
    public void notify(ListenerVariable variable) {

        String orderId = variable.getTask().getOrderId();
        UpdateWrapper<TechnologyProcess> uw = new UpdateWrapper<>();
        uw.lambda().set(TechnologyProcess::getStatus, OrderStatusEnum.APPROVAL_SECOND.getCode()).eq(TechnologyProcess::getId, orderId);
        technologyProcessDao.update(uw);

    }

}
